﻿using Common.ConsoleSysMessages;
using ConsoleCommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

/// <summary>
/// 编写控制台命令系统
/// </summary>
namespace ConsoleCommon
{


    public class ConsoleSysCommon
    {
        [Common.ConsoleSysMessages.Command("Clear","清空控制台")]
        public bool Clear(string[] Command)
        {

            System.Console.Clear();

            System.Console.WriteLine("参数:" + Command.ToString());

            return false;
        }

        [Common.ConsoleSysMessages.Command("Esc", "结束控制台")]
        public bool Esc(string[] Command)
        {
            //System.Console.Clear();
            Thread.CurrentThread.Abort();

            return true;
        }
    }

}


/// <summary>
/// 用于测试TimerDome
/// </summary>
namespace TimerTestDome
{

    /// <summary>
    /// 注册个技能取消事件
    /// </summary>
    public class SkillCandle : Utils.Runnable
    {
        public static int id = 0;

        public override void Run()
        {
            base.Run();
            id++;
            //Console.WriteLine("技能取消:" + id);
        }
    }

    class Program
    {

        static void Main(string[] args)
        {

            //注册控制台命令 
            ConsoleCommandManager.GetInstance().RegisterCommand(new ConsoleSysCommon());
            
            //注册
            Utils.PingTimer.getInstance().Register(new SkillCandle(), 1000, true);
            Utils.PingTimer.getInstance().Start();
            string Name = "";

            while (true)
            {
                Name = Console.ReadLine();
                string[] pr = Name.Split(' ');

                ConsoleCommandManager.GetInstance().Call(pr[0], pr);
            }

            //Console.ReadLine();
            //while (true) ;
        }

        public static void ThreadProc()
        {
            //注册
            Utils.PingTimer.getInstance().Register(new SkillCandle(), 1000, true);
            Utils.PingTimer.getInstance().Start();
        }
    }

}
